import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_demo/route_widget/FifthPage.dart';
class FourthPage extends StatelessWidget {
  final  arguments;
  const FourthPage({Key? key,this.arguments}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print(arguments);
    return Scaffold(appBar: AppBar(
      title: Text("FourthPage组件"),
    ),
    body: Container(
      child:Column(
        children: <Widget>[
          Text(
            "${arguments != null ? arguments['content'] : "ThirdPage"}",style: TextStyle(
              color: Colors.red,
              fontSize: 30,
              fontWeight: FontWeight.bold
          ),
          ),
          RaisedButton(
            onPressed: (){
              Navigator.pushAndRemoveUntil(context,
                  MaterialPageRoute(builder: (context)=>FifthPage()),
                      (route) => true);//true 与正常压栈跳转一样
            },
            child: Text("pushAndRemoveUntil true保留跳转的当前栈"),
          ),
          RaisedButton(
              onPressed: (){
                Navigator.pushNamedAndRemoveUntil(
                    context, "/fifth",
                    //栈里只存在一个界面
                    // ModalRoute.withName("/fourth"),//清除旧栈需要保留的栈 不清除就不写这句
                        (route)=>false//true保留跳转的当前栈   false 不保留  一般用于跳转主页
                );
              },
            child: Text("pushNamedAndRemoveUntil,finish当前页"),
          ),
          RaisedButton(
              onPressed: (){
               Navigator.pushReplacement(context,
                   MaterialPageRoute(builder: (context)=>FifthPage()));//当前页面在栈中的位置替换成跳转的页面
              },
            child: Text("pushReplacement 当前页面在栈中的位置替换成跳转的页面"),
          ),
          RaisedButton(
              onPressed: () {
                Navigator.pushReplacementNamed(context, "/fifth");
                // Navigator.popAndPushNamed(context, "/fifth");
              },
            child: Text("pushReplacement 当前页面在栈中的位置替换成跳转的页面"),
          ),
          RaisedButton(
              onPressed: () {
               // Navigator.popUntil(context, (route) => false);
                Navigator.pushNamed(context, "/fifth");
              },
            child: Text("popUntil pop到指定界面"),
          ),
        ],
      )
    ),);
  }
}
